package com.jinduplan.planmanager.mvp.presenter

import com.cxz.kotlin.baselibs.ext.ss
import com.cxz.kotlin.baselibs.mvp.BasePresenter
import com.fphoenixcorneae.util.toast.ToastUtil
import com.jinduplan.planmanager.mvp.contract.ProjectUploadContract
import com.jinduplan.planmanager.mvp.model.ProjectUploadModel

/**
 * @author admin
 * @date 2018/11/20
 * @desc
 */
class ProjectUploadPresenter :
    BasePresenter<ProjectUploadContract.Model, ProjectUploadContract.View>(),
    ProjectUploadContract.Presenter {

    override fun createModel(): ProjectUploadContract.Model? = ProjectUploadModel()
    override fun getProjectList(page: Int, limit: Int) {
        mModel?.getProjectList(page, limit)?.ss(mModel, mView, page == 1, onSuccess = {
            if (it.code == 200) {
                mView?.setProjectListData(it.data)
            }
        }, onError = {
            ToastUtil.show(it.msg)
        })
    }


}